<?php
$loader->requireOnce('includes/Datasource_sql.class.php');

class SurgeryServiceGroup extends ORDataObject{
	var $surgery_service_group_id	= '';
	var $name						= '';
	var $parent_id					= '';
	
	var $_table			=	'surgery_service_group';
	var $_key			=	'surgery_service_group_id';
	var	$_internalName	=	'SurgeryServiceGroup';
	
	const	SURGERY		=	1;	// ID of group 'Surgery' in $_table, should update this if there is any change  
	const	ECTOMY		=	2;	// ID of group 'Ectomy'
	
	public function SurgeryServiceGroup(){
		parent::ORDataObject();
	}
	
	/**
	 * List all group of surgery services in a catergory
	 * @return array
	 */
	public function listSurgeryServiceGroup($catergoryId='0'){
		$field      =   L10nHelper::changeField(L10nHelper::getLocale(), 'name');        
        
        $ds		= new Datasource_sql();
        $sql	= array(
        	'cols'		=>	"grp.surgery_service_group_id group_id, grp.$field group_name",
        	'from'		=>	"$this->_table grp",
        	'orderby'	=>	"group_name"
        );
        if($catergoryId !== '0'){
        	$sql['where'] = "grp.parent_id=$catergoryId";
        }
        else{
        	$sql['where'] = "grp.parent_id=0";
        }
        $ds->setup($this->_db, $sql);
        return $ds->toArray();
	}
	
}
?>